#include "Average.hh"
#include "AutoLock.hh"

Average::Average()
{
	AverageVal = 0;
	NumOfData = 0;
}

ResultOf Average::addData(double InputData)
{
	AutoLock AutoKey(&LockOfAverage);
	
	++NumOfData;
	AverageVal = AverageVal * (NumOfData -1) / NumOfData + InputData / NumOfData;
	
	return RETURN_OK;
}

double Average::tellAverage()
{
	return AverageVal;
}
